package com.example.caorl.job5thread.interrupt;

import java.util.concurrent.locks.LockSupport;

public class LockSupportThread extends Thread{

    public volatile boolean stopFlag = false;

    @Override
    public void run() {
        for (int i = 0;i<1000000000;i++) {
            if (stopFlag) {
                System.out.println("-----------------我被停止了---------------");
                LockSupport.park();
            }
            System.out.println("---------" + i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        LockSupportThread lockSupportThread = new LockSupportThread();
        lockSupportThread.start();
        Thread.sleep(2000);
        lockSupportThread.stopFlag = true;
        Thread.sleep(2000);
        lockSupportThread.stopFlag = false;
    }

}
